<template>
  <el-form :model="ruleForm" :rules="rules" status-icon ref="ruleForm" label-width="0" class="demo-ruleForm el-regForm" size="small">
    <el-form-item prop="email" >
      <el-input prop="email" placeholder="请输入邮箱" v-model="ruleForm.email" class="login-input login-user">
        <i slot="prefix" class="el-yonghu iconfont"></i>
      </el-input>
    </el-form-item>
    <el-form-item prop="password" >
      <el-input prop="password" placeholder="请输入密码" type="password" v-model="ruleForm.password" class="login-input">
        <i slot="prefix" class="el-icon-test iconfont"></i>
      </el-input>
    </el-form-item>
    <el-form-item prop="code" >
      <el-input prop="code" placeholder="请输入验证码" @keyup.enter.native="goHome('ruleForm')" v-model="ruleForm.code" class="login-code">
        <i slot="prefix" class="el-yanzhengma iconfont"></i>
      </el-input>
      <div class="code_pic" @click="refreshCode">
        <!-- <s-identify :identifyCode="identifyCode"></s-identify> -->
      </div>
    </el-form-item>
    <el-form-item >
      <div>
          <input type="checkbox" v-model="checked" class="login-item login-rem" />
          <span>记住密码</span>
          <router-link to="/forgetpass" class="forget-pw">忘记密码？</router-link>
        </div>
    </el-form-item>
    <el-form-item>
        <el-button type="primary" class="login-input login-btn" @click="goHome('ruleForm')" round>登 录</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  name: "userLogin",
  data() {
    return {
      ruleForm:{
          email:'admin',
          password:'cqc123',
          code:'',
        },
        rules:{
          email:[
            {required:true,message:'邮箱不能为空！'},
            {pattern: /^[\w!#$%&'*+/=?^_`{|}~-]+(?:\.[\w!#$%&'*+/=?^_`{|}~-]+)*@(?:[\w](?:[\w-]*[\w])?\.)+[\w](?:[\w-]*[\w])?$/, message: '邮箱格式错误，请重新填写！',trigger:'blur'},
            // {validator:validateEmail,trigger:'submit'}
          ],
          password:[
            {required:true,message:'密码不能为空！'},
            {pattern:/^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,}$/,message:'密码必须包含英文和数字，不能纯英文或者数字!'},
            // {validator:validatePass,trigger:'submit'}
          ],
          code:[
            {required:true,message:'输入验证码错误！'},
            // {validator:validateCode,trigger:'blur'}
          ],
        },
        identifyCode: "",
        checked: false,
    }
  },
  created() {
    
  },
  
  computed: {
   
  },
 
  methods: {
        goHome(){
          this.$router.push('/wel/index');
          let username = this.ruleForm.email;
          let password = this.ruleForm.password;
          this.$store.dispatch('LoginByUsername',this.ruleForm);
        },
        refreshCode(){

        },
  }
};
</script>

<style scoped>
    .login-input{
        width: 260px;
    }
</style>
